package com.hymjweb.demo.hymj.native_bill_manage.sign_choose_detail.mapper;

import com.hymjweb.demo.hymj.native_bill_manage.sign_choose_detail.bean.BNativeBillSignChooseDetailPojo;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.jdbc.SQL;
import org.springframework.stereotype.Component;

import java.util.List;

@Mapper
@Component
public interface BNativeBillSignChooseDetailMapper {

    class BNativeBillSignChooseDetailMapperProvider{

        public String queryBillSignStatusByBillId(String billId){
            String sql= new SQL() {{
                SELECT("t.* ");
                FROM("b_native_bill_sign_choose_detail t ");
                WHERE("t.native_bill_id = #{billId}");
            }}.toString();
            return sql;
        }

        public String insert(BNativeBillSignChooseDetailPojo pojo){
            String sql = new SQL() {{
                INSERT_INTO("b_native_bill_sign_choose_detail");
                VALUES("id","#{id}");
                VALUES("native_bill_id","#{nativeBillId}");
                VALUES("sign_status_id","#{signStatusId}");
                VALUES("create_time", "#{createTime}");
                VALUES("create_user_id", "#{createUserId}");
                VALUES("update_time", "#{updateTime}");
                VALUES("update_user_id", "#{updateUserId}");
            }}.toString();
            return sql;
        }

        public String delete(String id){
            String sql = new SQL() {{
                DELETE_FROM("b_native_bill_sign_choose_detail t");
                WHERE("t.id = #{id}");
            }}.toString();
            return sql;
        }

    }

    @Results(id = "bNativeBillSignChooseDetailMapperId",value = {
            @Result(column = "id", property = "id"),
            @Result(column = "native_bill_id", property = "nativeBillId"),
            @Result(column = "sign_status_id", property = "signStatusId"),
            @Result(column = "create_time", property = "createTime"),
            @Result(column = "create_user_id", property = "createUserId"),
            @Result(column = "update_time", property = "updateTime"),
            @Result(column = "update_user_id", property = "updateUserId")
    })
    @SelectProvider(type = BNativeBillSignChooseDetailMapperProvider.class, method = "queryBillSignStatusByBillId")
    List<BNativeBillSignChooseDetailPojo> queryBillSignStatusByBillId(String billId);


    @InsertProvider(type = BNativeBillSignChooseDetailMapperProvider.class, method = "insert")
    int insert(BNativeBillSignChooseDetailPojo pojo);


    @DeleteProvider(type = BNativeBillSignChooseDetailMapperProvider.class, method = "delete")
    int delete(String id);

}
